<script type="text/javascript">
  (function () {
    function onClick(aEv) {
      var container = aEv.target;
      var anchor = null;
      var url = null;
      var txt = null;

      // If any text actively selected...
      if (window.getSelection) {
        txt = window.getSelection().toString();
      } else if (document.getSelection) {
         txt = document.getSelection().toString();
      } else if (document.selection) {
         txt = document.selection.createRange().text
      }

      if (txt) {
       return; // ... then ignore
      }

      switch (container.nodeName) {
        case 'A':
          // fallthrough
        case 'INPUT':
          return;
      }

      // Traverse up the DOM to find the container tr tag or a tag
      while (!container.classList.contains('tr-link')) {
        if (!(container = container.parentNode) || container.nodeName === 'A') {
          return;
        }
      }

      // Find the anchor tag for redirection
      anchor = container.querySelector('a.tr-link-a');
      if (!anchor) {
        return;
      }

      // Check to see if the href tag exists
      url = anchor.getAttribute('href');
      if (!url) {
        return;
      }

      // Stop everything as soon as possible
      aEv.stopPropagation();
      aEv.preventDefault();

      // Redirect to the anchor href
      if ((aEv.ctrlKey || aEv.metaKey) && aEv.shiftKey) {
        window.open(url, '_blank').focus();
        return;
      }

      if (aEv.ctrlKey || aEv.metaKey) {
        window.open(url, '_blank').blur();
        return;
      }

      window.location = url;
    }

    function onDOMContentLoaded(aEv) {
      var i = undefined;
      var el = undefined;
      var els = document.querySelectorAll('tr.tr-link');

      // Place handler on everything within the tr.tr-link
      for (i = 0, el; el = els[i++];) {
        el.addEventListener('click', onClick);
      }
    }

    document.addEventListener('DOMContentLoaded', onDOMContentLoaded);

  })();
</script>
